//
//  LWBaseController.swift
//  Microblog
//
//  Created by Roman on 17/1/4.
//  Copyright © 2017年 Roman. All rights reserved.
//

import UIKit

class LWBaseController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        
    }

    //LWBaseController(rootViewController: vc)  在内部进行了push操作 ,进行压栈
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        //完成统一操作: 1. 进入子页面隐藏底部的tabBar 2. 设置返回按钮
        //如果设置根视图控制器的话 就不要设置返回按钮
        let count = self.childViewControllers.count
        
        if count > 0 {
            
            //自定义返回按钮
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", imageName: "navigationbar_back_withtext", target: self, action: #selector(close))
            
            //隐藏底部tabBar
            viewController.hidesBottomBarWhenPushed = true
        }
        
        super.pushViewController(viewController, animated: animated)
        
    }
    //实现close
    @objc private func close()  {
        //pop
        self.popViewController(animated: true)
    
    }
   

}
